package dao.pojo;

import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * PurchaseInfo entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "purchase_info", catalog = "onlinemall")
public class PurchaseInfo implements java.io.Serializable {

	// Fields

	private Integer purchaseId;
	private String purchaseName;
	private Float purchasePrice;
	private Timestamp purchaseDate;
	private String supplier;
	private Set<PurchaseCommodityInfo> purchaseCommodityInfos = new HashSet<PurchaseCommodityInfo>(
			0);
	private Set<CommodityInfo> commodityInfos = new HashSet<CommodityInfo>(0);

	// Constructors

	/** default constructor */
	public PurchaseInfo() {
	}

	/** minimal constructor */
	public PurchaseInfo(String purchaseName, Float purchasePrice,
			Timestamp purchaseDate, String supplier) {
		this.purchaseName = purchaseName;
		this.purchasePrice = purchasePrice;
		this.purchaseDate = purchaseDate;
		this.supplier = supplier;
	}

	/** full constructor */
	public PurchaseInfo(String purchaseName, Float purchasePrice,
			Timestamp purchaseDate, String supplier,
			Set<PurchaseCommodityInfo> purchaseCommodityInfos,
			Set<CommodityInfo> commodityInfos) {
		this.purchaseName = purchaseName;
		this.purchasePrice = purchasePrice;
		this.purchaseDate = purchaseDate;
		this.supplier = supplier;
		this.purchaseCommodityInfos = purchaseCommodityInfos;
		this.commodityInfos = commodityInfos;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "purchase_id", unique = true, nullable = false)
	public Integer getPurchaseId() {
		return this.purchaseId;
	}

	public void setPurchaseId(Integer purchaseId) {
		this.purchaseId = purchaseId;
	}

	@Column(name = "purchase_name", nullable = false, length = 100)
	public String getPurchaseName() {
		return this.purchaseName;
	}

	public void setPurchaseName(String purchaseName) {
		this.purchaseName = purchaseName;
	}

	@Column(name = "purchase_price", nullable = false, precision = 12, scale = 0)
	public Float getPurchasePrice() {
		return this.purchasePrice;
	}

	public void setPurchasePrice(Float purchasePrice) {
		this.purchasePrice = purchasePrice;
	}

	@Column(name = "purchase_date", nullable = false, length = 19)
	public Timestamp getPurchaseDate() {
		return this.purchaseDate;
	}

	public void setPurchaseDate(Timestamp purchaseDate) {
		this.purchaseDate = purchaseDate;
	}

	@Column(name = "supplier", nullable = false, length = 100)
	public String getSupplier() {
		return this.supplier;
	}

	public void setSupplier(String supplier) {
		this.supplier = supplier;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "purchaseInfo")
	public Set<PurchaseCommodityInfo> getPurchaseCommodityInfos() {
		return this.purchaseCommodityInfos;
	}

	public void setPurchaseCommodityInfos(
			Set<PurchaseCommodityInfo> purchaseCommodityInfos) {
		this.purchaseCommodityInfos = purchaseCommodityInfos;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "purchaseInfo")
	public Set<CommodityInfo> getCommodityInfos() {
		return this.commodityInfos;
	}

	public void setCommodityInfos(Set<CommodityInfo> commodityInfos) {
		this.commodityInfos = commodityInfos;
	}

}